/*****************************************************************************
 * $LastChangedDate: 2011-04-23 21:07:07 -0400 (Sat, 23 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   HUD.
 *//*
 * LEGAL:   COPYRIGHT (C) 2007 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef HUD_HUD_HH
#define HUD_HUD_HH 1

#include <set>
#include <osg/Version>

#if OSG_VERSION_LESS_THAN(3,0,0)
#include <osg/CameraNode>
#else
#include <osg/Camera>
#endif
#include "base/singleton.hh"

namespace hud {

#define GET_HUD() (hud::Hud::GetInstance())

/// Indeed, these HUD ortho dimensions remain constant.
/// Think of these, not as a 1280x1024 screen, but as ratios for scaling text.
/// Because of how osg::Text functions, if these were updated with the current screen size,
/// the text wouldn't be scaled.
const fp HUD_ORTHO_X1 = 0;
const fp HUD_ORTHO_X2 = 1280;
const fp HUD_ORTHO_Y1 = 0;
const fp HUD_ORTHO_Y2 = 1024;

class HudBox;

////////////////////////////////////////////////////////////////////////////////
/// @brief HUD.
///
class Hud
{
PREVENT_COPYING(Hud)
private:
    Hud( void );
    ~Hud();

public:
                    DEFINE_GetInstance( Hud )  // Singleton
    void            Enable( const bool enable = true );
    RefPtr<Node>    GetNode( void ) { return mCamera.get(); }
    void            Attach( RefPtr<Node> node );
    void            Attach( shptr<HudBox> hudBox );
    void            Detach( RefPtr<Node> node );
    void            Detach( shptr<HudBox> hudBox );

private:
    // Stateset (such as disabled fog) has no effect on osg::CameraNode,
    // so an intermediate osg::Group is used to hold nodes of the HUD.
    CLASS_VAR Hud*           msInstance;
#if OSG_VERSION_LESS_THAN(3,0,0)
    RefPtr<osg::CameraNode>  mCamera;
#else
    RefPtr<osg::Camera>  mCamera;
#endif
    RefPtr<osg::Group>       mGroup;         ///< holds HUD nodes, defines stateset
    std::set<shptr<HudBox> > mHudBoxes;      ///< needed to hold references
};

} // namespace hud

#endif // HUD_HUD_HH
